home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / Python-1.4 / Source / Amiga / Python_netlib / usleep.c < prev    next >
C/C++ Source or Header  |  1994-09-29  |  1KB  |  61 lines

  1. RCS_ID_C="$Id: usleep.c,v 4.1 1994/09/29 23:09:02 jraja Exp $"
  2. /*
  3.  *      usleep.c - suspend process for the specified time
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. #include <sys/param.h>
  11. #include <unistd.h>
  12. #include <sys/time.h>
  13. #include <sys/socket.h>
  14.  
  15. /****** net.lib/usleep *********************************************
  16.  
  17.     NAME
  18.     usleep - suspend process execution for the specified time
  19.  
  20.     SYNOPSIS
  21.     void usleep(unsigned int microseconds);
  22.  
  23.     FUNCTION
  24.         Process execution is suspended for number of microseconds
  25.         specified in 'microseconds'. The sleep will be aborted if any
  26.         of the break signals specified for the process is received
  27.         (only CTRL-C by default).
  28.  
  29.     PORTABILITY
  30.     UNIX
  31.  
  32.     INPUTS
  33.     'microseconds' - number of microseconds to sleep.
  34.  
  35.     RESULT
  36.         Does not return a value.
  37.  
  38.     NOTES
  39.         The sleep is implemented as a single select() call with all other
  40.         than time out argument as NULL.
  41.  
  42.     SEE ALSO
  43.     bsdsocket.library/select()
  44.  
  45. *****************************************************************************
  46. *
  47. */
  48.  
  49. void usleep(unsigned int usecs)
  50. {
  51.   struct timeval tv;
  52.  
  53.   tv.tv_sec = 0;
  54.   while (usecs >= 1000000) {
  55.     usecs -= 1000000;
  56.     tv.tv_sec++;
  57.   }    
  58.   tv.tv_usec = usecs;
  59.   select(0, 0, 0, 0, &tv);
  60. }
  61.